/**   
*    
* @file
* @brief
* @文件名	: StarappGetUserInfoImp
* @版权所有	: 网龙应用软件开发一部
* @作  者	: chenqian
* @创建时间	: 2014-11-4 下午3:14:38 
* @文件描述	:  
* @version	Ver 1.1
*/
package com.common.allCommon;

import android.text.TextUtils;

import com.product.android.business.bean.UserInfo;
import com.product.android.business.login.BindUser;
import com.product.android.business.login.IGetUserInfo;

/**
 * 明星的实现IGetUserInfo
 * <br>Created 2014-11-4 下午3:14:38
 * @version  
 * @author   chenqian		
 *
 * @see 	 
 */

public class StarappGetUserInfoImp implements IGetUserInfo{
	private UserInfo mCurrentUserInfo;
	private BindUser mCurrentUser;
	public void setUserInfo(UserInfo userInfo){
		mCurrentUserInfo = userInfo;
	}
	public void setBindUser(BindUser bindUser){
		mCurrentUser = bindUser;
	}
	public UserInfo getUserInfo(){
		if(null == mCurrentUserInfo){
			mCurrentUserInfo = new UserInfo();
		}
		return mCurrentUserInfo;
	}
	@Override
	public BindUser getBindUser(){
		if(null == mCurrentUser){
			mCurrentUser = new BindUser();
		}
		return mCurrentUser;
	}
	@Override
	public int getId() {
		return getUserInfo().getIdentity();
	}
	@Override
	public long getUapUid() {		
		return getUserInfo().getUapUid();
	}
	@Override
	public String getTicekt() {		
		return getUserInfo().getTicket();
	}
	@Override
	public String getAccount() {
		return getUserInfo().getUserName();
	}
	@Override
	public String getBlowFish() {
		return getUserInfo().getBlowfish();
	}
	@Override
	public long getOapUid() {
		return getUserInfo().getOapUid();
	}
	@Override
	public int getOapUnitId() {
		return getUserInfo().getOapUnitId();
	}

	@Override
	public String getPwdTime() {
		return "";
	}
	@Override
	public String getBindUapAccount() {
		return "";
	}
	@Override
	public String getLastLoginTime() {
		return getUserInfo().getLastLoginDt();
	}

	@Override
	public boolean isOrgAdmin() {
		return false;
	}

	@Override
	public int getType() {
		return -1;
	}

	@Override
	public boolean isAutoLogin() {
		return getUserInfo().getIsAutoLogin();
	}

	@Override
	public boolean isSavePwd() {
		return getUserInfo().getIsSaveAccount();
	}

	@Override
	public boolean isCurrentUser() {
		return true;
	}

	@Override
	public int getLoginType() {
		return 0;//LOGIN_TYPE_UAP = 0;
	}

	@Override
	public String getSid() {
		return getUserInfo().getSessionId();
	}

	@Override
	public String getNickName() {
		return getUserInfo().getUserNickName();
	}

	@Override
	public void clearSid() {		
		getUserInfo().setSessionId("");
	}

	@Override
	public void updateSid(String sid) {
		if (TextUtils.isEmpty(sid) || mCurrentUserInfo == null) {
			return;
		}
		if (mCurrentUserInfo instanceof UserInfo) {
			UserInfo info = (UserInfo) mCurrentUserInfo;
			info.setSessionId(sid);
		} 
	}

	@Override
	public void reLoadUserFromDb() {		
	}

	
	@Override
	public boolean updateBindUserToDb() {
		return false;
	}

	@Override
	public String getEtrasValue(int id, String keyName) {
		return getUserInfo().getmVar_ext();
	}

	@Override
	public void putEtrasValue(int id, String keyName, String value) {		
	}

}
